From 0de2a323654a47d19629e78cd2c67a1bcff635ea Mon Sep 17 00:00:00 2001 From: Mat Date: Sat, 21 Mar 2020 14:57:19 +0200 Subject: Don't call player movement hook if nothing changed (#4517) Co-authored-by: peterbell10 --- src/ClientHandle.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ce6d4c981..351e7203a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -839,8 +839,28 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, Vector3d NewPosition(a_PosX, a_PosY, a_PosZ); Vector3d OldPosition = GetPlayer()->GetPosition(); + double OldStance = GetPlayer()->GetStance(); auto PreviousIsOnGround = GetPlayer()->IsOnGround(); + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wfloat-equal" + #endif + + if ( + (OldPosition == NewPosition) && + (OldStance == a_Stance) && + (PreviousIsOnGround == a_IsOnGround) + ) + { + // Nothing changed, no need to do anything + return; + } + + #ifdef __clang__ + #pragma clang diagnostic pop + #endif + // If the player has moved too far, "repair" them: if ((OldPosition - NewPosition).SqrLength() > 100 * 100) { -- cgit v1.2.3